using UnityEngine;
using System.Collections;

public class EnemyShotting : MonoBehaviour {
	public Rigidbody bullet;
	public float speed = 20;
	public Transform explosion;	private Rigidbody bulletInstantiated = null; 
		
	void Update () {
		
		//if((Input.GetButtonDown("Jump") || Input.GetButtonDown("Fire1"))&& (bulletInstantiated == null))
		if((Random.Range(0, 1000) == 0) && (bulletInstantiated == null))
		{
			bulletInstantiated = Instantiate(bullet, 			// o objeto para ser instanciado
														transform.position, // a posicao no plano 3D
														transform.rotation) // a rotacao do objeto
														as Rigidbody;		// um Castingo para converter para o Rigibody
			
			// move o objeto
			bulletInstantiated.velocity = transform.TransformDirection(new Vector3(0,0,speed));
			
			bulletInstantiated.tag = "EnemyShot";
			
			//audio.Play();
			// Desativa a colisao entro a nave e o objeto
			
			//Physics.IgnoreCollision(projetilInstanciado.collider, transform.root.collider);
			
		}
	
	}
}
